﻿using ConfExpert.Forms.Base;
using ConfExpert.Utility;
using DevExpress.Utils;
using DevTeam;
using System;
using System.Data;
using System.Drawing;

namespace ConfExpert.Forms.Ithalat
{
    public partial class Masraf : XForm
    {
        public Masraf()
        {
            InitializeComponent();
        }

        string REF
        {
            get
            {
                return "KRB.T6";    // +(((DateTime)beiAy1.EditValue).Year % 10).ToStr();
            }
        }

        private void Masraf_Load(object sender, EventArgs e)
        {
            gridView1.Init("GetImportList3", REF);

            foreach (DataRow r in AppSession.Lookups.HesapPlani.Rows)
            {
                string hp = r["HesapPlaniId"].ToStr();

                if (gridView1.Columns.Contains(gridView1.Columns[hp]))
                {
                    gridView1.FormatAsNumber(1, hp);
                    gridView1.AddSummary(hp);
                    gridView1.SetCaptions(hp + ":" + r["Abbr"].ToStr());
                    gridView1.Columns[hp].ToolTip = r["HesapKodu"].ToStr() + ". " + r["Name"].ToStr();
                }
            }

            gridView1.RowCellStyle += gridView1_RowCellStyle;

            gridView1.MakeReadOnly();
            //gridView1.MakeColumnInvisible("Customer");
            //gridView1.MakeColumnInvisible("Ay", "Oran", "Musteri", "Sezon");
            gridView1.Columns["Oran"].VisibleIndex = 100;
            gridView1.Columns["Oran"].ToolTip = "Faturanın ilgili dosyadaki payı";
            gridView1.FormatAsPercentage("Oran");
            gridView1.FormatAsNumber(1, "ToplamMasraf", "LineTotals", "FaturaToplami", "Miktar");
            gridView1.AddSummary("ToplamMasraf", "LineTotals", "FaturaToplami", "Miktar");
            gridView1.ShowOnlyNonblankColumns();
            gridView1.BestFitColumns();

            //gridView1.SetViewCaption("Masraf Dağılımı");
        }

        void gridView1_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
        {
            if (e.RowHandle > -1)
            {
                switch (e.Column.FieldName)
                {
                    case "ToplamMasraf":
                        e.Appearance.Font = new Font(AppearanceObject.DefaultFont, FontStyle.Bold);
                        return;
                }
            }
        }
    }
}
